#include "string.h"
#include "Clock.h"
#define INC_VALUE 0.1

Clock::Clock(): hours(0), minutes(0), seconds(0), incValue(INC_VALUE) { }

Clock::Clock(double iv): hours(0), minutes(0), seconds(0), incValue(iv) { }

Clock::Clock(int hours,int minutes,int seconds): hours(hours), minutes(minutes), seconds(seconds), incValue(INC_VALUE) { }

Clock::Clock(const Clock& orig): hours(orig.hours), minutes(orig.minutes), seconds(orig.seconds), incValue(orig.incValue) { }

Clock::~Clock() { }

void Clock::tick() {
    seconds += incValue;
    while(seconds >= 60) {
        minutes++;
        seconds -= 60;
    }
    while(minutes >= 60) {
        hours++;
        minutes -= 60;
    }
}

double Clock::getSeconds() {
    return seconds;
}

int Clock::getMinutes() {
    return minutes;
}

int Clock::getHours() {
    return hours;
}

char* Clock::getTimeString() {

	char string[11];
	for(int i = 0; i < 10; i++)
		string[i] = ' ';
	string[10] = '\0';

    int tenthSeconds = 10 * (seconds - (int)seconds);
    int sec = (int)seconds;

    char h[3];
    int_to_char(hours,h);
    check_zero(h);
    char m[3];
    int_to_char(minutes,m);
    check_zero(m);
    char s[3];
    int_to_char(sec,s);
    check_zero(s);
    char ts[2];
    int_to_char(tenthSeconds,ts);

    my_strcopy(h,string);
    my_strcopy(":",string,2);
    my_strcopy(m,string,3);
    my_strcopy(":",string,5);
    my_strcopy(s,string,6);
    my_strcopy(".",string,8);
    my_strcopy(ts,string,9);
	
	return string;    
    
}
